package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.a;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.c;
import java.util.Collections;
import java.util.List;

public final class afz implements agc {
    private final List<c> ˊ;
    private int ˋ;
    private final aef[] ˎ;
    private int ˏ;
    private boolean ॱ;
    private long ॱॱ;

    public afz(List<c> list) {
        this.ˊ = list;
        this.ˎ = new aef[list.size()];
    }

    public void ˏ() {
        this.ॱ = false;
    }

    public void ˏ(ady o_ady, a aVar) {
        for (int i = 0; i < this.ˎ.length; i++) {
            c cVar = (c) this.ˊ.get(i);
            aVar.ˊ();
            aef ˊ = o_ady.ˊ(aVar.ˏ(), 3);
            ˊ.ˎ(Format.ˏ(aVar.ˎ(), "application/dvbsubs", null, -1, 0, Collections.singletonList(cVar.ˋ), cVar.ˎ, null));
            this.ˎ[i] = ˊ;
        }
    }

    public void ˋ(long j, int i) {
        if ((i & 4) != 0) {
            this.ॱ = true;
            this.ॱॱ = j;
            this.ˏ = 0;
            this.ˋ = 2;
        }
    }

    public void ˋ() {
        if (this.ॱ) {
            for (aef ˋ : this.ˎ) {
                ˋ.ˋ(this.ॱॱ, 1, this.ˏ, 0, null);
            }
            this.ॱ = false;
        }
    }

    public void ˊ(anc o_anc) {
        int i = 0;
        if (!this.ॱ) {
            return;
        }
        if (this.ˋ == 2 && !ˊ(o_anc, 32)) {
            return;
        }
        if (this.ˋ != 1 || ˊ(o_anc, 0)) {
            int ˋ = o_anc.ˋ();
            int ˊ = o_anc.ˊ();
            aef[] o_aefArr = this.ˎ;
            int length = o_aefArr.length;
            while (i < length) {
                aef o_aef = o_aefArr[i];
                o_anc.ˋ(ˋ);
                o_aef.ˎ(o_anc, ˊ);
                i++;
            }
            this.ˏ += ˊ;
        }
    }

    private boolean ˊ(anc o_anc, int i) {
        if (o_anc.ˊ() == 0) {
            return false;
        }
        if (o_anc.ʽ() != i) {
            this.ॱ = false;
        }
        this.ˋ--;
        return this.ॱ;
    }
}
